package com.yiyong.myabtis_genetion.utils;

import com.yiyong.myabtis_genetion.constant.CommonConstants;
import com.yiyong.myabtis_genetion.exception.GenerationCodeException;
import org.apache.velocity.app.Velocity;

import java.util.Properties;

/**
 * VelocityEngine工厂
 *
 * @author yiyong
 */
public class VelocityInitializer {

    public static void initVelocity() {
        Properties ps = new Properties();
// 加载classpath目录下的vm文件
        try {
            ps.setProperty("resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
            // 定义字符集
            ps.setProperty(Velocity.INPUT_ENCODING, CommonConstants.UTF8);
            // 初始化Velocity引擎，指定配置Properties
            Velocity.init(ps);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
